package com.orientsec.autotest.project.system.autoComCaseType.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.orientsec.autotest.framework.aspectj.lang.annotation.Log;
import com.orientsec.autotest.framework.aspectj.lang.enums.BusinessType;
import com.orientsec.autotest.project.system.autoComCaseType.domain.AutoComCaseType;
import com.orientsec.autotest.project.system.autoComCaseType.service.IAutoComCaseTypeService;
import com.orientsec.autotest.framework.web.controller.BaseController;
import com.orientsec.autotest.framework.web.page.TableDataInfo;
import com.orientsec.autotest.framework.web.domain.AjaxResult;
import com.orientsec.autotest.common.utils.poi.ExcelUtil;

/**
 * 组合案例种类信息操作处理
 * 
 * @author autotest
 * @date 2020-01-09
 */
@Controller
@RequestMapping("/system/autoComCaseType")
public class AutoComCaseTypeController extends BaseController
{
    private String prefix = "system/autoComCaseType";
	
	@Autowired
	private IAutoComCaseTypeService autoComCaseTypeService;
	
	@RequiresPermissions("system:autoComCaseType:view")
	@GetMapping()
	public String autoComCaseType()
	{
	    return prefix + "/autoComCaseType";
	}
	
	/**
	 * 查询组合案例种类列表
	 */
	@RequiresPermissions("system:autoComCaseType:list")
	@PostMapping("/list")
	@ResponseBody
	public TableDataInfo list(AutoComCaseType autoComCaseType)
	{
		startPage();
        List<AutoComCaseType> list = autoComCaseTypeService.selectAutoComCaseTypeList(autoComCaseType);
		return getDataTable(list);
	}
	
	
	/**
	 * 导出组合案例种类列表
	 */
	@RequiresPermissions("system:autoComCaseType:export")
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(AutoComCaseType autoComCaseType)
    {
    	List<AutoComCaseType> list = autoComCaseTypeService.selectAutoComCaseTypeList(autoComCaseType);
        ExcelUtil<AutoComCaseType> util = new ExcelUtil<AutoComCaseType>(AutoComCaseType.class);
        return util.exportExcel(list, "autoComCaseType");
    }
	
	/**
	 * 新增组合案例种类
	 */
	@GetMapping("/add")
	public String add()
	{
	    return prefix + "/add";
	}
	
	/**
	 * 新增保存组合案例种类
	 */
	@RequiresPermissions("system:autoComCaseType:add")
	@Log(title = "组合案例种类", businessType = BusinessType.INSERT)
	@PostMapping("/add")
	@ResponseBody
	public AjaxResult addSave(AutoComCaseType autoComCaseType)
	{		
		return toAjax(autoComCaseTypeService.insertAutoComCaseType(autoComCaseType));
	}

	/**
	 * 修改组合案例种类
	 */
	@GetMapping("/edit/{casetypeId}")
	public String edit(@PathVariable("casetypeId") Integer casetypeId, ModelMap mmap)
	{
		AutoComCaseType autoComCaseType = autoComCaseTypeService.selectAutoComCaseTypeById(casetypeId);
		mmap.put("autoComCaseType", autoComCaseType);
	    return prefix + "/edit";
	}
	
	/**
	 * 修改保存组合案例种类
	 */
	@RequiresPermissions("system:autoComCaseType:edit")
	@Log(title = "组合案例种类", businessType = BusinessType.UPDATE)
	@PostMapping("/edit")
	@ResponseBody
	public AjaxResult editSave(AutoComCaseType autoComCaseType)
	{		
		return toAjax(autoComCaseTypeService.updateAutoComCaseType(autoComCaseType));
	}
	
	/**
	 * 删除组合案例种类
	 */
	@RequiresPermissions("system:autoComCaseType:remove")
	@Log(title = "组合案例种类", businessType = BusinessType.DELETE)
	@PostMapping( "/remove")
	@ResponseBody
	public AjaxResult remove(String ids)
	{		
		return toAjax(autoComCaseTypeService.deleteAutoComCaseTypeByIds(ids));
	}
	
}
